package com.snow.springboot.service;

import com.alibaba.excel.context.AnalysisContext;
import com.snow.springboot.pojo.domain.DiagnosExcelInfo;
import com.snow.springboot.pojo.domain.DiagnoseInfo;
import org.springframework.beans.BeanUtils;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @Package: com.snow.springboot.service
 * @ClassName: DiagnoseExcelListener
 * @Description:诊断信息的excel解析
 * @author: lurui
 * @Date: 2018/10/30 2:05 PM
 * @version:
 */
public class DiagnoseExcelListener extends BaseListenner {

    private List<DiagnoseInfo> datas = new ArrayList<>();

    @Override
    public void invoke(Object object, AnalysisContext analysisContext) {
        DiagnosExcelInfo excelInfo = (DiagnosExcelInfo) object;
        DiagnoseInfo diagnoseInfo = new DiagnoseInfo();
        BeanUtils.copyProperties(excelInfo, diagnoseInfo);
        diagnoseInfo.setState("1");
        diagnoseInfo.setCreateTime(new Date());
        datas.add(diagnoseInfo);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {

    }

    @Override
    public List<DiagnoseInfo> getDatas() {
        return datas;
    }
}
